package com.tangula.controller;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

public interface PagingQueryController {
	
	default Pageable toPageRequest(int index, int size, Sort.Order ... orders) {
		return PageRequest.of(index - 1,size,
				Sort.by(orders));
	}
	
	default Pageable toPageRequestDescId(int index, int size) {
		return toPageRequest(index,size,
				new Sort.Order(Direction.DESC, "id"));
	}
	
	
	
	
}
